package com.kaifamiao.Fighter;

import java.util.Scanner;

public class Fighter {

    /**
     *
     */

    static Scanner sc = new Scanner(System.in);

    static String name[] = new String [4];

    static String myOrders[] = new String[4];

    static double times[] = new double[4];

    static String address[] = new String[4];

    static int state[] = new int[4];

    static double sumPrice[] = new double[4];

    static String cigarette[] = {"黑兰州","软中华","南京九五"};

    static double price[] = {18,70,100};

    static int dianZan[] = new int[3];

    /**
     *
     */

    public  void addOrder(){

        String answer = "y";

        ok:do{
            for(int j = 0;j< name.length;j++){
                if(name[j] ==null){
                    System.out.println("********我要买烟********");
                    System.out.println("********香烟信息********");
                    System.out.println("序号\t名称\t价格\t点赞");
                    for (int i =0;i<cigarette.length;i++){
                        System.out.println((i+1)+ "\t"+cigarette[i]+"\t"+price[i]+"\t"+dianZan[i]);
                    }
                    System.out.println("*********************");
                    System.out.println("请选择菜单序号：");
                    int index = sc.nextInt();
                    while(index <1||index>myOrders.length-1){
                        System.out.println("香烟编号在1-3之间，请重新输入");
                        index= sc.nextInt();
                    }
                    System.out.println("请输入订烟人姓名：");
                    String nameOrder = sc.next();
                    System.out.println("请输入订烟数量：");
                    int numOrder = sc.nextInt();

                    double priceOrder = price[index - 1]*numOrder;

                    double rate = (priceOrder>=50)?0:5;

                    double sumPriceOrder = priceOrder + rate;

                    String smoke = cigarette[index-1]+numOrder+"包";
                    System.out.println("请输入订烟时间：");
                    double timeOrder = sc.nextDouble();
                    while(timeOrder<8||timeOrder>20){
                        System.out.println("订烟时间为早上8点-晚上20点，请重新输入：");
                        timeOrder = sc.nextInt();
                    }
                    System.out.println("请输入送餐地址：");
                    String addOrder = sc.next();
                    System.out.println("定烟成功！");

                    System.out.println("您定的是"+smoke);
                    System.out.println("送烟时间"+timeOrder+"点");
                    System.out.println("烟费是"+priceOrder+"运费是"+rate+"，总计"+sumPriceOrder+"元");

                    name[j] = nameOrder;
                    myOrders[j] = smoke;
                    times[j] = timeOrder;
                    address[j] = addOrder;
                    sumPrice[j] = sumPriceOrder;
                    break ;
                }
                else if(j == name.length-1){
                    System.out.println("您买的烟已经满了");
                    break ok;
                }
            }
            System.out.println("是否继续点餐（y/n）：");
            answer = sc.next();

        }while("y".equals(answer.toLowerCase()));
    }

public void showOrder(){

    System.out.println("******查看餐袋******");
    System.out.println("序号\t订餐人\t");

    for(int i = 0;i < name.length ;i ++){

        if(name[i] != null){
            System.out.println((i + 1)+"\t"
                +name[i]+"\t"+ myOrders[i]+"\t"
                +times[i]      +"\t"
                + address[i] + "\t"
                + state[i]+"\t"
                +sumPrice[i]);
        }
    }
}

/**
 *
 */

public static void confirmOrder(){
    System.out.println("******");
    System.out.println();

}


}
